package com.hc.likelistenmusic.receiver

import android.content.BroadcastReceiver
import android.content.Context
import android.content.Intent
import android.content.Intent.CATEGORY_LAUNCHER
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.content.Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED
import com.hc.likelistenmusic.manager.ActivityManager

class NotificationClickJumpTopActivityReceiver : BroadcastReceiver() {

    override fun onReceive(context: Context, intent: Intent) {
        val currentActivity = ActivityManager.getCurrentActivity()
        var i = Intent(Intent.ACTION_MAIN).apply {
            addCategory(CATEGORY_LAUNCHER)
            setClass(context, currentActivity.javaClass)
            setFlags(FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_RESET_TASK_IF_NEEDED)
        }
        context.startActivity(i)
    }
}